package qiyu.live.gift.provider.rpc;

import jakarta.annotation.Resource;
import org.qiyu.live.common.interfaces.utils.ConvertBeanUtils;
import qiyu.live.gift.dto.RedPacketConfigReqDTO;
import qiyu.live.gift.dto.RedPacketConfigRespDTO;
import qiyu.live.gift.dto.RedPacketReceiveDTO;
import qiyu.live.gift.interfaces.IRedPacketConfigRpc;
import qiyu.live.gift.provider.dao.po.RedPacketConfigPO;
import qiyu.live.gift.provider.service.IRedPacketConfigService;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-11-12
 * Time: 17:09
 */
public class RedPacketConfigRpcImpl implements IRedPacketConfigRpc {

    @Resource
    private IRedPacketConfigService redPacketConfigService;

    @Override
    public RedPacketConfigRespDTO queryRedPacketConfigByAnchorId(Integer anchorId) {
        return ConvertBeanUtils.convert(redPacketConfigService.
                queryRedPacketConfigByAnchorId(anchorId), RedPacketConfigRespDTO.class);
    }

    @Override
    public boolean insertOne(RedPacketConfigReqDTO redPacketConfigReqDTO) {
        return redPacketConfigService.insertOne(ConvertBeanUtils.convert(redPacketConfigReqDTO, RedPacketConfigPO.class));
    }

    @Override
    public boolean updateById(RedPacketConfigReqDTO redPacketConfigReqDTO) {
        return redPacketConfigService.updateById(ConvertBeanUtils.convert(redPacketConfigReqDTO, RedPacketConfigPO.class));
    }

    @Override
    public boolean prepareRedPacket(Integer anchorId) {
        return redPacketConfigService.prepareRedPacket(anchorId);
    }

    @Override
    public RedPacketReceiveDTO redPacketReceive(String code) {
        return redPacketConfigService.redPacketReceive(code);
    }
}